﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Collections;
using Entity;

namespace Public
{
    public class Context
    {

        public static string 保留小数位 = "f6";

        private static Context c = null;

        private Context()
        {
        }

        public static Context GetInstance()
        {
            if (c != null)
            {
                return c;
            }
            c = new Context();
            return c;
        }

        public string FrmTitle
        {
            get;
            set;
        }
        public string LoginOrgName
        {
            get;
            set;
        }
        public string PasswordKey
        {
            get
            {
                return "0";//huangzhi
            }
        }

        public ushort Oracle密钥
        {
            get { return 18; }
        }

        public string UpdateURL
        {
            get;
            set;
        }
        public Hashtable hs { set; get; }
        public string OracleDataSource { set; get; }
        public string OracleUser { set; get; }
        public string OraclePassword { set; get; }

        public string ERP服务器IP地址 { set; get; }
        public string ERP数据库名称 { set; get; }
        public string ERP登录用户 { set; get; }
        public string ERP登录密码 { set; get; }


        public string 工作中心 { set; get; }
        public string 线体 { set; get; }
        public string 工序 { set; get; }
        public string 班次 { set; get; }
        public string 工序线体 { set; get; }

        public string 工作中心ID { set; get; }
        public string 线体ID { set; get; }
        public string 工序ID { set; get; }
        public string 班次ID { set; get; }
        public string 工序线体ID { set; get; }

        public string 事业部ID { set; get; } //20140723吴
        public string 事业部名称 { set; get; }//20140723吴

        public string 公司别 { set; get; }

        public ADMMA 登录用户 { get; set; }
        public SYS_USER LoginUser { get; set; }

        public string _分隔字符 = "|";

        public string _退出密码 = "123456";

        public string DEVOracleDataSource { set; get; }
        public string DEVOracleUser { set; get; }
        public string DEVOraclePassword { set; get; }

        #region 获取FTP服务器用户密码

        /// <summary>
        /// 获取FTP配置用户名和密码
        /// zhanghang at 20130718
        /// </summary>
        /// <param name="filepath"></param>
        /// <param name="nodeName"></param>
        /// <returns></returns>
        public string GetValue(string filepath, string nodeName)
        {
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(filepath);
            XmlNode node = xmlDoc.SelectSingleNode("/Settings/" + nodeName);
            if (node == null)
            {
                XmlElement root = xmlDoc.DocumentElement; // 获取根节点
                XmlElement sRoot = xmlDoc.CreateElement(nodeName);
                sRoot.InnerText = "";
                root.AppendChild(sRoot);
                xmlDoc.Save(filepath);
                return "";
            }
            else
            {
                return node.InnerText;
            }
        }
        #endregion

    }
}
